package com.huawei.appgallery.assistantdock.buoydock.webview.delegate;

import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import com.huawei.appgallery.agwebview.api.delegate.GeneralWebViewDelegate;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appmarket.service.common.protocol.AppActivityProtocol;
import com.huawei.appmarket.service.common.protocol.AppActivityProtocol.Request;
import com.huawei.hwid.core.constants.HwAccountConstants;
import com.huawei.secure.android.common.intent.SafeIntent;
import java.util.LinkedHashMap;
import o.bab;
import o.beo.f;
import o.bht;
import o.AccountBussinessListener;
import o.ccp;
import o.cjk;
import o.cjm;
import o.cjo;
import o.djl;
import o.Logger;
import o.ContentManager;
import o.enx;
import o.eod;
import o.eoj;
import o.epr;
import o.fbp;

public class BuoyWebviewDelegate extends GeneralWebViewDelegate {
    private boolean ʾ = false;

    public boolean ʼ() {
        return false;
    }

    public void ˋ() {
        ˎˎ();
        super.ˋ();
        this.ʼ.getSettings().setBlockNetworkImage(true);
    }

    private void ˎˎ() {
        String userId = UserSession.getInstance().getUserId();
        final String userId2 = this.ॱॱ != null ? this.ॱॱ.getUserId() : "";
        if (UserSession.getInstance().isLoginSuccessful()) {
            ˊ(userId, userId2);
            return;
        }
        final djl o_djl = new djl(ʻॱ());
        o_djl.ˋ(ˏॱ().getString(f.ﾟ));
        o_djl.setCancelable(false);
        o_djl.setCanceledOnTouchOutside(false);
        o_djl.show();
        eoj.ˋ().ˎ("BuoyWebviewDelegate", new AccountBussinessListener(this) {
            final /* synthetic */ BuoyWebviewDelegate ˏ;

            public void onAccountBusinessResult(ccp o_ccp) {
                this.ˏ.ॱ(o_ccp.ˎ, o_djl, userId2);
                eoj.ˋ().ˊ("BuoyWebviewDelegate");
            }
        });
        eod.ॱ(ContentManager.getInstant().getContext());
    }

    private void ॱ(final int i, final djl o_djl, final String str) {
        try {
            ʻॱ().runOnUiThread(new Runnable(this) {
                final /* synthetic */ BuoyWebviewDelegate ˊ;

                public void run() {
                    if (!(o_djl == null || this.ˊ.ˊ())) {
                        o_djl.dismiss();
                    }
                    if (i == 102) {
                        this.ˊ.ˊ(UserSession.getInstance().getUserId(), str);
                        if (this.ˊ.ʾ) {
                            this.ˊ.ʽ(this.ˊ.ॱॱ.getUrl());
                            return;
                        }
                        return;
                    }
                    this.ˊ.ˊ("", str);
                }
            });
        } catch (Throwable e) {
            Logger.ˋ("BuoyWebviewDelegate", "processLoginResult exception", e);
        }
    }

    private void ˊ(String str, String str2) {
        if (TextUtils.isEmpty(str2)) {
            str2 = str;
        }
        if (TextUtils.isEmpty(str) || !str.equals(r6)) {
            Object notice = this.ॱॱ != null ? this.ॱॱ.getNotice() : null;
            if (!TextUtils.isEmpty(notice)) {
                ˋ(ˏॱ(), notice, 1);
            }
            if (ͺ()) {
                Context ʻॱ = ʻॱ();
                cjo appActivityProtocol = new AppActivityProtocol();
                appActivityProtocol.ॱ(new Request());
                appActivityProtocol.ˋ().ˋ("customColumn.personcenter");
                cjm o_cjm = new cjm("market.activity", appActivityProtocol);
                o_cjm.ॱ(ʻॱ).setFlags(HwAccountConstants.FLAG_TRANSLUCENT_STATUS);
                cjk.ˎ().ˋ(ʻॱ, o_cjm);
                ʻॱ.finish();
                return;
            }
            return;
        }
        this.ʾ = true;
    }

    public void ʽ(String str) {
        if (this.ʾ) {
            super.ʽ(str);
        }
    }

    private String ˏ(Activity activity) {
        return new SafeIntent(activity.getIntent()).getStringExtra("packageName");
    }

    public void ॱˋ() {
        super.ॱˋ();
        if (this.ˊ instanceof Activity) {
            Activity activity = (Activity) this.ˊ;
            SafeIntent safeIntent = new SafeIntent(activity.getIntent());
            if (safeIntent.getIntExtra("orientation", -1) == 1) {
                activity.setRequestedOrientation(1);
            } else if (safeIntent.getIntExtra("orientation", -1) == 2) {
                activity.setRequestedOrientation(6);
            }
        }
    }

    public void ˎ(Object obj) {
        if (obj instanceof fbp) {
            ((fbp) obj).setFromBuoy(true);
            ((fbp) obj).setPackageName(ˏ(ʻॱ()));
        }
    }

    public boolean ˉ() {
        return true;
    }

    public String ʾ() {
        return "BuoyWebviewDelegate";
    }

    public LinkedHashMap ॱˎ() {
        LinkedHashMap linkedHashMap = new LinkedHashMap(4);
        if (epr.ˎ().ˏ() != null) {
            linkedHashMap.put("third_id", epr.ˎ().ˏ());
        }
        linkedHashMap.put("page_id", enx.ॱ(this.ॱᐝ));
        linkedHashMap.put("service_type", Integer.valueOf(4));
        linkedHashMap.put("user_agent", ॱॱ().trim());
        return linkedHashMap;
    }

    public bab ˋˊ() {
        return new bht();
    }
}
